<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "classrooms".
 *
 * @property integer $id
 * @property string $name
 */
class ClassroomModel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'classrooms';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['name'], 'string', 'max' => 100],
            [['name'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '教室名称',
        ];
    }
    
    /**
     * 获取所有物资
     *
     */
    public function getAllClassrooms(){
    	$classrooms=[];
    	$res=self::find()->asArray()->all();
    	if($res){
    		foreach ($res as $k =>$list){
    			$classrooms[$list['name']]=$list['name'];
    			 
    		}
    	}
    
    	return $classrooms;
    
    }
}
